package org.demo.treeeditor.mode;

import java.awt.event.KeyEvent;

import org.demo.treeeditor.StateMachine;

public class EditMode  extends AbstractMode {

	

	public EditMode(StateMachine stateMachine) {
		super(stateMachine);
	}


	@Override
	public void init() {
		setAction(10,"baseMode");//enter
		setAction(27,"escape");//escape
		setAction(8,"backSpace");//backspace
		setAction(16,"shift");//shift
	}

	
	@Override
	public void handleOtherEvent(KeyEvent e) {
		stateMachine.getTextPrompt().type(e.getKeyChar()+"");
	}
	
	public void baseMode(){
		stateMachine.getTextPrompt().save();
		stateMachine.getBoxLayoutEngine().reLayout();
		escape();
	}
	
	public void backSpace(){
		stateMachine.getTextPrompt().backSpace();
	}
	
	public void escape(){
		stateMachine.getTextPrompt().hide();		
		stateMachine.reSetCurrentNode();
		stateMachine.setState(StateMachine.StateEnum.base);
	}
	
	public void shift(){
		
	}
	
	

	
}
